#include "hi_type.h"

/************* DeGamma Luts **************/
HI_U32 u32DeGmmLut_PQ[64] = {							 //U21.0 [0,2097151]
	0,	0,	0,	1,	1,	3,	5,	7,
	11,	15,	21,	28,	36,	46,	58,	87,
	125,	174,	238,	317,	416,	537,	686,	867,
	1085,	1346,	1659,	2031,	2472,	2993,	3607,	4328,
	5173,	6163,	7317,	8663,	10229,	12048,	14160,	16607,
	19440,	22718,	26507,	30884,	35936,	41765,	48488,	56239,
	65172,	87326,	116731,	155767,	207621,	276578,	368425,	491012,
	655041,	875176,	1012329,	1171636,	1356864,	1572464,	1823705,	2097151,
};

// DeHLG Curve: BBC HDR
HI_U32 u32DeGmmLut_HLG[64] = {
0,
11,
43,
96,
171,
385,
684,
1069,
1539,
2095,
2736,
3463,
4275,
5173,
6156,
8379,
10944,
13851,
17100,
20691,
24624,
28899,
33516,
38475,
43776,
49419,
55404,
61731,
68400,
75411,
82764,
90459,
98496,
106875,
115596,
124659,
134064,
143811,
153900,
164331,
175105,
186562,
199066,
212713,
227607,
243862,
261603,
280966,
302098,
350333,
407789,
476226,
557745,
654846,
770507,
908276,
1072379,
1267850,
1379179,
1500683,
1633293,
1778022,
1935979,
2097151 };












// DeSLF Curve: AVS HDR
HI_U32 u32DeGmmLut_SLF[64] = {
0,
0,
0,
0,
0,
1,
1,
1,
1,
2,
3,
4,
5,
6,
8,
13,
21,
32,
48,
71,
102,
144,
200,
274,
370,
495,
653,
854,
1106,
1420,
1807,
2281,
2860,
3561,
4405,
5416,
6622,
8054,
9747,
11739,
14076,
16807,
19990,
23687,
27971,
32922,
38630,
45200,
52747,
71324,
95665,
127495,
169142,
223836,
296205,
393144,
525439,
711028,
832978,
982197,
1167842,
1403678,
1711403,
2097151 };

// DeGamma Curve: SDR
HI_U32 u32DeGmmLut_24[64] = {
0,
3,
18,
49,
97,
257,
513,
877,
1358,
1966,
2709,
3594,
4627,
5817,
7168,
10377,
14297,
18967,
24424,
30701,
37831,
45844,
54768,
64630,
75458,
87276,
100108,
113979,
128910,
144925,
162043,
180286,
199675,
220228,
241965,
264904,
289065,
314464,
341120,
369049,
398269,
428795,
460644,
493832,
528375,
564287,
601585,
640282,
680393,
764917,
855269,
951557,
1053890,
1162369,
1277098,
1398174,
1525694,
1659752,
1729263,
1800442,
1873302,
1947853,
2024107,
2097151 };

// DeHisi Curve: Hisi HDR
HI_U32 u32DeHisiLut[64] = {							 //U20.0 [0,1048575]
	0		 ,
	0		 ,
	0		 ,
	1		 ,
	1		 ,
	2		 ,
	4		 ,
	7		 ,
	10		 ,
	16		 ,
	24		 ,
	35		 ,
	51		 ,
	71		 ,
	99		 ,
	136		 ,
	184		 ,
	246		 ,
	325		 ,
	425		 ,
	550		 ,
	706		 ,
	899		 ,
	1135	 ,
	1422	 ,
	1771	 ,
	2191	 ,
	2694	 ,
	3293	 ,
	4005	 ,
	4846	 ,
	5837	 ,
	6999	 ,
	8356	 ,
	9938	 ,
	11776	 ,
	13905	 ,
	16365	 ,
	19202	 ,
	22466	 ,
	26216	 ,
	30518	 ,
	35445	 ,
	41085	 ,
	47535	 ,
	54910	 ,
	63341	 ,
	72982	 ,
	84015	 ,
	96655	 ,
	111156	 ,
	127829	 ,
	147049	 ,
	169280	 ,
	195096	 ,
	225228	 ,
	260609	 ,
	302458	 ,
	352398	 ,
	412641	 ,
	486278	 ,
	577771	 ,
	693812	 ,
	1048575
};


HI_U32 u32DeGmmLut_xvYCC[64] = {							 //U21.0 [0,2097151]
	62825  ,
	62825  ,
	62825  ,
	62825  ,
	96197  ,
	130554 ,
	162602 ,
	192373 ,
	219898 ,
	245208 ,
	268340 ,
	289330 ,
	308217 ,
	325043 ,
	339852 ,
	352694 ,
	363623 ,
	372697 ,
	379983 ,
	385559 ,
	389572 ,
	393216 ,
	396860 ,
	400873 ,
	406449 ,
	413735 ,
	422809 ,
	433738 ,
	446580 ,
	461389 ,
	478215 ,
	497102 ,
	518092 ,
	541224 ,
	566534 ,
	594059 ,
	623830 ,
	655878 ,
	690235 ,
	726927 ,
	765983 ,
	807428 ,
	851289 ,
	897590 ,
	946353 ,
	997603 ,
	1051361,
	1107648,
	1166486,
	1227895,
	1291894,
	1358503,
	1427741,
	1463351,
	1499625,
	1536565,
	1574173,
	1612452,
	1651404,
	1655707,
	1655707,
	1655707,
	1655707,
	1655707
};

/************* ToneMapping Luts **************/
// ToneMapping Lut: Default
HI_U32 u32TMLut[64] = {//U8.8 [0,65535]
	11127,
	11127,
	11123,
	11119,
	11116,
	11101,
	11086,
	11072,
	11057,
	11042,
	11028,
	11013,
	10955,
	10897,
	10783,
	10671,
	10560,
	10451,
	10237,
	10028,
	9826 ,
	9629 ,
	9437 ,
	8721 ,
	8078 ,
	7500 ,
	6980 ,
	6511 ,
	6087 ,
	5703 ,
	5354 ,
	5038 ,
	4750 ,
	4487 ,
	4247 ,
	4027 ,
	3825 ,
	3167 ,
	2684 ,
	2320 ,
	2039 ,
	1816 ,
	1637 ,
	1489 ,
	1365 ,
	1260 ,
	1170 ,
	1092 ,
	1024 ,
	964	 ,
	910	 ,
	862	 ,
	819	 ,
	683	 ,
	585	 ,
	512	 ,
	455	 ,
	410	 ,
	372	 ,
	341	 ,
	315	 ,
	293	 ,
	273	 ,
	256
/*
4160,
4160,
4160,
4160,
4160,
4160,
3771,
3418,
3134,
2899,
2700,
2531,
2383,
2254,
2140,
2038,
1946,
1788,
1638,
1489,
1365,
1260,
1170,
1092,
1024,
819	,
683	,
512	,
410	,
341	,
293	,
256
*/
};

// ToneMapping Lut: HDR10  to SDR
HI_U32 u32TMLut_HDR2SDR[64] = {			   //U9.7 [0,65535]
	   0,	5000,	7000,	9000,	10568,	10091,	9768,	9531,
	9348,	9200,	9078,	8974,	8675,	8478,	8220,	8045,
	7912,	7801,	7619,	7467,	7332,	7209,	7093,	6680,
	6317,	5988,	5686,	5407,	5149,	4909,	4685,	4477,
	4282,	4099,	3929,	3769,	3619,	3104,	2698,	2560,
	2560,	2560,	2560,	2560,	2560,	2560,	2560,	2560,
	2560,	2560,	2560,	2560,	2560,	2560,	2560,	2560,
	2560,	2560,	2560,	2560,	2560,	2560,	2560,	2560,
};

// ToneMapping Lut: TCHDR to HDR10  to SDR
HI_U32 u32TMLutTCHDR2HDR102SDR[64] = {				   //U9.7 [0,65535]
	14337,
	14337,
	12537,
	11692,
	11122,
	9752 ,
	8944 ,
	8378 ,
	7953 ,
	7616 ,
	7342 ,
	7112 ,
	6469 ,
	6065 ,
	5579 ,
	5277 ,
	5065 ,
	4902 ,
	4660 ,
	4482 ,
	4338 ,
	4216 ,
	4109 ,
	3767 ,
	3498 ,
	3270 ,
	3070 ,
	2890 ,
	2728 ,
	2580 ,
	2445 ,
	2321 ,
	2206 ,
	2101 ,
	2003 ,
	1912 ,
	1828 ,
	1545 ,
	1329 ,
	1161 ,
	1024 ,
	910	 ,
	819	 ,
	745	 ,
	683	 ,
	630	 ,
	585	 ,
	546	 ,
	512	 ,
	482	 ,
	455	 ,
	431	 ,
	410	 ,
	341	 ,
	293	 ,
	256	 ,
	228	 ,
	205	 ,
	186	 ,
	171	 ,
	158	 ,
	146	 ,
	137	 ,
	128

};

// ToneMapping Lut: AVS to SDR
HI_U32 u32TMLut_SLF2SDR[64] = {
34636,
32569,
30781,
29256,
27936,
24013,
21380,
19461,
17986,
16808,
15841,
15030,
12752,
11324,
9593,
8558,
7858,
7346,
6638,
6163,
5816,
5548,
5332,
4750,
4384,
4116,
3902,
3722,
3565,
3425,
3298,
3181,
3073,
2973,
2879,
2790,
2707,
2413,
2170,
1966,
1792,
1642,
1513,
1399,
1300,
1213,
1136,
1067,
1005,
950,
900,
855,
814,
682,
640,
640,
640,
640,
640,
640,
640,
640,
640,
640 };

// ToneMapping Lut: AVS to HDR10
HI_U32 u32TMLutAVS2HDR10[64] = {				   //U8.8 [0,65535]
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256
};

// ToneMapping Lut: HDR10 to HLG
HI_U32 u32TMLut_HDR2HLG[64] = {
39465,
22149,
19732,
18443,
17580,
15662,
14638,
13953,
13443,
13041,
12710,
12431,
11618,
11074,
10351,
9866,
9506,
9221,
8790,
8469,
8215,
8007,
7831,
7319,
6976,
6722,
6521,
6355,
6215,
6094,
5988,
5894,
5809,
5732,
5662,
5597,
5537,
5335,
5175,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120,
5120 } ;

HI_U32 u32TMLut_SDR2HLG[64] = {
41319,
41319,
20659,
14205,
15849,
19232,
18541,
17993,
17292,
16732,
16277,
15848,
14671,
13881,
12796,
12053,
11559,
11156,
10522,
10046,
9683,
9393,
9153,
8460,
8040,
7714,
7462,
7277,
7123,
6992,
6879,
6779,
6689,
6627,
6556,
6504,
6459,
6298,
6208,
6134,
6096,
6086,
6078,
6095,
6109,
6141,
6183,
6220,
6279,
6335,
6389,
6463,
6530,
6860,
7269,
7751,
8316,
8993,
9756,
10674,
11744,
13037,
14676,
16369 };

HI_U32 u32TMLut_SDR2HDR[64] = {
32768,
10820,
5410,
3743,
4521,
6551,
6799,
6947,
6926,
6905,
6889,
6853,
6774,
6714,
6604,
6510,
6474,
6434,
6354,
6285,
6236,
6201,
6175,
6092,
6070,
6040,
6019,
6024,
6030,
6038,
6047,
6056,
6064,
6093,
6105,
6131,
6159,
6248,
6370,
6475,
6600,
6745,
6877,
7033,
7176,
7338,
7508,
7668,
7855,
8037,
8212,
8418,
8610,
9474,
10474,
11619,
12945,
14521,
16320,
18500,
21080,
24253,
28345,
32733 };

// ToneMapping Lut: AVS to HDR10
HI_U32 u32TMLut_Linear[64] = {			   // U8.8 [0,65535]
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256
};

// ToneMapping Lut: BBC to HDR10
HI_U32 u32TMLut_HLG2HDR[64] = {
1783,
3566,
4096,
4442,
4705,
5405,
5861,
6208,
6492,
6733,
6944,
7132,
7734,
8192,
8884,
9410,
9840,
10205,
10809,
11303,
11722,
12090,
12417,
13466,
14263,
14914,
15468,
15952,
16384,
16775,
17132,
17461,
17768,
18055,
18324,
18579,
18820,
19679,
20410,
21049,
21619,
22134,
22605,
23041,
23445,
23823,
24179,
24515,
24834,
25136,
25425,
25702,
25967,
26931,
27774,
28526,
29206,
29828,
30402,
30936,
31435,
31904,
32348,
32768 };

// ToneMapping Lut: BBC to SDR
HI_U32 u32TMLut_HLG2SDR[64] = {
7931,
15858,
18209,
19740,
20900,
23964,
25936,
27414,
28603,
29599,
30456,
31208,
33529,
35184,
37473,
39029,
40180,
41081,
42431,
43428,
44221,
44885,
45460,
47258,
48625,
49757,
50731,
51588,
52352,
53039,
53661,
54226,
54743,
55216,
55650,
56049,
56417,
57618,
58479,
59081,
59478,
59712,
59809,
59794,
59684,
59492,
59233,
58914,
58545,
58132,
57682,
57200,
56691,
54458,
52041,
49564,
47104,
44711,
42415,
40235,
38180,
36251,
34448,
32768 };

// ToneMapping Lut: Hisi to HDR10
HI_U32 u32TMLutHisi2HDR10[32] = {				   //U8.8 [0,65535]
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256,
	256
};

/************* Smap Luts **************/
HI_U32 u32SMLut_HDR2SDR[32] = {				   //U2.8 [0,1023]
	77,		128,	144,	169,	188,	205,	242,	246,
	251,	254,	256,	256,	256,	256,	256,	256,
	256,	255,	251,	183,	179,	179,	179,	179,
	179,	179,	179,	179,	179,	179,	179,	179,
};

HI_U32 u32SMLut_Linear[32] = {
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256,
256 };

HI_U32 u32SMLutAVS2SDR[64] = {				   //U2.8 [0,1023]
    248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	248,
	240,
	234,
	230,
	226,
	222,
	218,
	214,
	205,
	199,
	194,
	191,
	188,
	185,
	183,
	181,
	179,
	177,
	175,
	173,
	172,
	170,
	165,
	159,
	155,
	151,
	147,
	143,
	140,
	137,
	134,
	131,
	128,
	126,
};

/************* Gamma Luts **************/
HI_U32 u32GmmLut0[64] = {//U12.0 [0,4095]
0	,
72	,
144	,
216	,
288	,
360	,
426	,
486	,
541	,
592	,
641	,
686	,
730	,
772	,
812	,
850	,
887	,
923	,
957	,
991	,
1024,
1055,
1086,
1116,
1146,
1174,
1203,
1230,
1257,
1284,
1310,
1335,
1360,
1409,
1456,
1502,
1547,
1590,
1632,
1673,
1713,
1753,
1791,
1829,
1866,
1902,
1937,
1972,
2006,
2138,
2261,
2378,
2489,
2595,
2697,
2889,
3068,
3237,
3397,
3549,
3694,
3833,
3966,
4095
};

/******************* Gmm-8 Lut Params *************************/
HI_U32 u32GmmLut_PQ10000[64] = {
0,
304,
400,
466,
517,
657,
749,
820,
878,
927,
970,
1008,
1129,
1220,
1354,
1454,
1533,
1600,
1708,
1794,
1865,
1926,
1980,
2146,
2267,
2361,
2440,
2506,
2564,
2616,
2662,
2704,
2742,
2777,
2810,
2841,
2869,
2969,
3050,
3119,
3178,
3231,
3278,
3321,
3360,
3395,
3428,
3459,
3488,
3515,
3540,
3564,
3587,
3668,
3736,
3794,
3846,
3892,
3933,
3971,
4006,
4038,
4067,
4095 };

HI_U32 u32GmmLut_PQ1000[64] = {
0,
108,
151,
181,
206,
278,
327,
367,
400,
429,
454,
477,
551,
609,
697,
765,
820,
867,
945,
1008,
1061,
1108,
1149,
1279,
1376,
1454,
1519,
1575,
1624,
1668,
1708,
1744,
1778,
1809,
1838,
1865,
1891,
1980,
2054,
2118,
2173,
2222,
2267,
2307,
2344,
2378,
2410,
2440,
2467,
2494,
2518,
2542,
2564,
2644,
2712,
2771,
2823,
2869,
2912,
2950,
2986,
3019,
3050,
3079 };

HI_U32 u32PQLut[64] = {            //U12.0 [0,4095]
	0	,
	304	,
	400	,
	466	,
	517	,
	657	,
	749	,
	820	,
	878	,
	927	,
	970	,
	1008,
	1129,
	1220,
	1354,
	1454,
	1533,
	1600,
	1708,
	1794,
	1865,
	1926,
	1980,
	2146,
	2267,
	2361,
	2440,
	2506,
	2564,
	2616,
	2662,
	2704,
	2742,
	2777,
	2810,
	2841,
	2869,
	2969,
	3050,
	3119,
	3178,
	3231,
	3278,
	3321,
	3360,
	3395,
	3428,
	3459,
	3488,
	3515,
	3540,
	3564,
	3587,
	3668,
	3736,
	3794,
	3846,
	3892,
	3933,
	3971,
	4006,
	4038,
	4067,
	4095
};


//HLG Curve
HI_U32 u32GmmLut_HLG[64] = {
0,
28,
39,
48,
55,
78,
96,
111,
124,
136,
147,
157,
192,
222,
271,
313,
350,
384,
443,
496,
543,
586,
627,
768,
887,
991,
1086,
1173,
1254,
1330,
1402,
1470,
1536,
1598,
1659,
1717,
1773,
1982,
2165,
2313,
2436,
2541,
2633,
2714,
2788,
2854,
2916,
2972,
3024,
3073,
3119,
3162,
3203,
3346,
3466,
3569,
3660,
3740,
3812,
3878,
3939,
3995,
4047,
4095 };

// Gamma Curve
HI_U32 u32GmmLut_22[64] = {            //U12.0 [0,4095]
	0,	26,	36,	44,	50,	68,	82,	93,
	103,	112,	120,	128,	154,	175,	211,	240,
	266,	289,	329,	364,	396,	425,	451,	543,
	618,	684,	744,	798,	847,	894,	938,	979,
	1019,	1057,	1093,	1128,	1161,	1285,	1396,	1498,
	1591,	1679,	1761,	1839,	1913,	1984,	2052,	2118,
	2181,	2242,	2301,	2358,	2413,	2622,	2812,	2988,
	3153,	3307,	3454,	3593,	3726,	3854,	3977,	4095,
};

HI_U32 u32GmmLut_24[64] = {
0,
40,
54,
64,
72,
96,
114,
128,
140,
152,
162,
171,
202,
228,
270,
304,
334,
360,
406,
446,
481,
513,
542,
642,
724,
794,
857,
914,
966,
1015,
1060,
1103,
1144,
1183,
1220,
1256,
1290,
1416,
1527,
1629,
1722,
1808,
1889,
1966,
2039,
2108,
2174,
2237,
2298,
2357,
2414,
2469,
2522,
2721,
2902,
3068,
3222,
3367,
3503,
3632,
3756,
3873,
3986,
4095 };

